import request from '@/utils/request'

// 查询Training materials database列表
export function listTraining(query) {
  return request({
    url: '/quick/training/list',
    method: 'get',
    params: query
  })
}

// 查询Training materials database详细
export function getTraining(id) {
  return request({
    url: '/quick/training/' + id,
    method: 'get'
  })
}

// 新增Training materials database
export function addTraining(data) {
  return request({
    url: '/quick/training',
    method: 'post',
    data: data
  })
}

// 修改Training materials database
export function updateTraining(data) {
  return request({
    url: '/quick/training',
    method: 'put',
    data: data
  })
}

// 删除Training materials database
export function delTraining(id) {
  return request({
    url: '/quick/training/' + id,
    method: 'delete'
  })
}

// ======================== 题库API ========================

// 查询培训测试题库表列表
export function listQuestions(query) {
  return request({
    url: '/quick/training/extra/question/list',
    method: 'get',
    params: query
  })
}

// 新增培训测试题库表
export function addQuestion(data) {
  return request({
    url: '/quick/training/extra/question',
    method: 'post',
    data: data
  })
}

// 修改培训测试题库表
export function updateQuestion(data) {
  return request({
    url: '/quick/training/extra/question',
    method: 'put',
    data: data
  })
}

// 删除培训测试题库表
export function delQuestion(id) {
  return request({
    url: '/quick/training/extra/question/' + id,
    method: 'delete'
  })
}


// ======================== 评论API ========================

// 查询评论列表
export function listComments(query) {
  return request({
    url: '/quick/training/extra/comment/list',
    method: 'get',
    params: query
  })
}

// 新增评论
export function addComment(data) {
  return request({
    url: '/quick/training/extra/comment',
    method: 'post',
    data: data
  })
}


// ======================== 考试API ========================

// 开始考试（获取题目）
export function startTest(testType) {
  return request({
    url: '/quick/training/extra/test/start',
    method: 'get',
    params: { testType }
  })
}

// 获取考试答案（用于答案对比）
export function getTestAnswers(testType) {
  return request({
    url: '/quick/training/extra/test/answers',
    method: 'get',
    params: { testType }
  })
}

// 提交试卷
export function submitTest(data) {
  return request({
    url: '/quick/training/extra/test/submit',
    method: 'post',
    data: data
  })
}

// 查询考试记录
export function listTestRecords(query) {
  return request({
    url: '/quick/training/extra/test/record',
    method: 'get',
    params: query
  })
}
